package pt.ipleiria.estg.es2.olamundo;

import java.util.Random;

import android.R.string;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity {

	
	private Random gerador = new Random();
	private int numeroGerado;
	private EditText txtNumero;
	
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        numeroGerado = gerador.nextInt(10)+1;
        txtNumero = (EditText) findViewById(R.id.txtNumero);
       
    }
    
    public void tentarNumero(View v){
    	String textIntroduzido = txtNumero.getText().toString();
    	int numeroIntroduzido = Integer.parseInt(textIntroduzido);
    	
    	if(numeroIntroduzido<numeroGerado){
    		Toast.makeText(this, "O meu numero e maior", Toast.LENGTH_SHORT).show();
    	} else if(numeroIntroduzido>numeroGerado){
    		Toast.makeText(this, "O meu numero e menor", Toast.LENGTH_LONG).show();
    		} else{
    		Toast.makeText(this, "Parabens!", Toast.LENGTH_SHORT).show();
    	}
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}
